package com.yn.pet.enums;

import lombok.Getter;

@Getter
public enum GenderEnum {
    //男
    MALE(1, "男", 1),
    //女
    FEMALE(2, "女", 1),
    //公
    MALE_PUBLIC(1, "公", 0),
    //母
    FEMALE_PUBLIC(2, "母", 0),
    ;
    private final Integer code;
    private final String name;
    private final Integer type;

    GenderEnum(Integer code, String name, Integer type) {
        this.code = code;
        this.name = name;
        this.type = type;
    }

    public static String getNameByCodeAndType(Integer code, PetTypeEnum petTypeEnum) {
        Integer type = 0;
        if (petTypeEnum == PetTypeEnum.MAN || petTypeEnum == PetTypeEnum.WOMAN) {
            type = 1;
        }
        for (GenderEnum value : GenderEnum.values()) {
            if (value.getCode().equals(code) && value.getType().equals(type)) {
                return value.getName();
            }
        }
        return null;
    }

    public static String getNameByCodeAndPetType(Integer code, Integer petType) {
        PetTypeEnum petTypeEnum = PetTypeEnum.getByCode(petType);
        return getNameByCodeAndType(code, petTypeEnum);
    }
}
